home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Serial-Port-Programming < prev    next >
Text File  |  1997-04-01  |  25KB  |  667 lines

  1.  
  2.   Linux Serial Port Programming Mini-Howto
  3.   Antonino Iannella, antonino@usa.net
  4.   Version 1.0, March 9th 1997
  5.  
  6.   1. Introduction
  7.  
  8.   This document describes how to program the RS-232 ports for serial
  9.   communications, under PC-Linux. It covers information about
  10.   the serial ports, RS232 connections, modem issues, and the C programming
  11.   logic.
  12.  
  13.   2. Background
  14.   
  15.   For our final year project, our group had to design a concept World
  16.   Wide Web browser. Our prototype was a hand-held device which plugged
  17.   into a PC's COM2 (25-pin) serial port. The user would issue commands
  18.   to the browser (eg Back, Open, etc) by sending character commands to
  19.   the PC. The browser software would detect it, and perform the required
  20.   operation.
  21.   
  22.   The method provided in the 'Linux I/O port programming mini-HOWTO'
  23.   did not act reliably. Often, an incorrect value would be received.
  24.   The information within provided a 100% reliable, quasi-POSIX-compliant
  25.   approach to communication.
  26.   
  27.   The program provided at the end of this 0 formed the basis of
  28.   the PC's communication program. This document is written from the
  29.   1 needed for the web browser project. It revolves around
  30.   C programming for Linux, for a 9600 baud device attached to COM2.
  31.  
  32.   3. Acknowledgements
  33.   
  34.   The information here comes mainly from these sources -
  35.     
  36.   Heavily based on the 'Serial Programming Guide for POSIX Compliant 
  37.   Operating Systems', at http://www.easysw.com/~mike/serial/, by
  38.   mike@easysw.com. If you need greater detail or more information, then
  39.   this is the place to visit. Most of the information in this 0
  40.   originated here.
  41.     
  42.   The 'Linux I/O port programming mini-HOWTO', by Riku Saikkonen
  43.   (rjs@spider.compart.fi). This document provides a different approach
  44.   to Linux serial programming.
  45.  
  46.   'The Linux Serial HOWTO', by Greg Hankins, greg.hankins@cc.gatech.edu
  47.   describes how to set up serial communications devices on a Linux box.
  48.   It describes many aspects of serial devices and 0.
  49.   
  50.   My two wonderful project partners: Gerel Enrile and Joyce Gong.
  51.  
  52.   4. Copyright
  53.   
  54.   This document is copyright (C) 1997 by Antonino Iannella.
  55.   It is covered under the general Linux HOWTO copyright agreement.
  56.   
  57.   It is intended for the general public. it may be reproduced and
  58.   distributed in whole or in part, using any electronic or physical
  59.   medium. However, this copyright notice must remain on all copies.
  60.   
  61.   Please forward question, suggestions, corrections, and all tidbits
  62.   of information to the author at antonino@usa.net
  63.   (or nettuno@light.iinet.net.au).
  64.   You will be acknowledged in future HOWTO revisions.
  65.   
  66.   5. RS-232 connections
  67.   
  68.   RS-232 is a standard for serial communications. It comes in different
  69.   varieties. The most common is RS-232C which defines a 'mark' bit as a 
  70.   voltage between -3V and -12V, and a 'space' bit as a voltage between 
  71.   +3V and +12V. RS-574 is the standard for 9-pin PC connectors and
  72.   voltages.
  73.   
  74.   RS-232 basically consists of wires for serial communications; sending
  75.   and receiving, timing, status, and handshaking.
  76.   You can use a null modem cable as your connector.
  77.   The following pins are what were used for our project.  We connected
  78.   the device to the DB-25 pin COM2 port. Please note that the Transmit
  79.   line from the PC must connect to the Receive line of the device, and
  80.   vice versa. Also, please note that a parallel port is different to a
  81.   serial port!
  82.   
  83.                           PC's pins   Device's pins
  84.       TxD   Transmit Data         2 - 3       RxD   Receive Data
  85.       RxD   Receive Data          3 - 2       TxD   Transmit Data
  86.       SG    Signal Ground         7 - 7       SG    Signal Ground
  87.  
  88.   
  89.   Refer to the Linux Serial HOWTO for more specialised connections, and
  90.   detailed RS-232 pins.
  91.   
  92.   6. Serial 0 and RS-232 definitions
  93.   
  94.   The way that data get transmitted in serial communications is, well,
  95.   serially. One data bit is sent at a time. Each bit is either on (or the
  96.   'mark' state), or off (or the 'space' state).
  97.   
  98.   The serial data throughput is usually expressed in bits-per-second (bps)
  99.   or baudot (baud). Throughput is the number of data bits (2 or off) that
  100.   may be sent in a second. Your modem might be able to support 115200 baud.
  101.   The project's web browser device was designed to run at 9600 baud.
  102.   
  103.   RS-232 provides 18 different signals. About 6 are available to UNIX for
  104.   programming.
  105.   
  106.   GND - Logic ground
  107.   
  108.         Very important. Acts as a reference voltage, so the devices know
  109.         the relative voltage of the data transmitted.
  110.         
  111.   TxD - Transmitted data
  112.   
  113.         Carries the data transmitted from your PC.
  114.         A 'mark' voltage is interpreted as 1,
  115.         while a 'space' voltage is interpreted as 0.
  116.         
  117.   RxD - Received data
  118.   
  119.         Carries the data transmitted to your PC from the other device.
  120.         
  121.   DCD - Data carrier detect
  122.  
  123.         Is sent from the other device to your PC. A 'space' voltage means
  124.         that the device is still connected, or 'on-line'. This signal is
  125.         not always used or available.
  126.         
  127.   DTR - Data terminal ready
  128.  
  129.         Is sent from your PC to tell the device that you are ready (space)
  130.         or not-ready (mark). DTR is usually enabled automatically whenever
  131.         you access the serial interface.
  132.         
  133.   CTS - Clear to send
  134.   
  135.         Is sent from the other device to your PC. 
  136.         A 'space' voltage means that your PC may send some data.
  137.         It is usually used to regulate the flow of serial data from your
  138.         PC, but it is not currently supported by all UNIX flavours.
  139.         
  140.   RTS - Request to send
  141.   
  142.         Is set to the 'space' voltage by your PC when it requests to send
  143.         more data. It also used to regulate data flow. Many systems leave
  144.         it on 'space' voltage all the time.
  145.         
  146.   7. Communication issues
  147.   
  148.   This section covers other issues of serial communication which might be
  149.   relevant to your particular application.
  150.   Since we are programming for asynchronous communication, we need the 
  151.   PCs/devices to know where each character starts and ends in the serial
  152.   data flow.
  153.  
  154.   In asynchronous mode, the serial data line stays in the mark state until
  155.   a character is sent. A 'start bit' is sent before each character; it is
  156.   always 0 and tells the PC/device that a character will follow.
  157.   After the start bit, the character's bits are sent, then a 'parity' bit,
  158.   and one or more stop bits.
  159.   
  160.   The parity bit is a checksum of the data bits, indicating the number of
  161.   1 bits it contained -
  162.   
  163.      Even parity  - parity bit is 1 if there is an even number of 1s
  164.      Odd parity   - parity bit is 1 if there is an odd number of 1s
  165.      Space parity - parity bit is always 0
  166.      Mark parity  - parity bit is 1
  167.      No parity    - no parity bit is sent or present.
  168.  
  169.   'Stop' bits come at the end of every character. There may be 1, 1.5, or 2
  170.   stop bits. They used to be used to give the computer time to process the
  171.   character, but now they are used to synchronise the computer to the
  172.   incoming characters.
  173.   
  174.   Asynchronous data is usually described like '8N1' - 8 data bits, no parity
  175.   bits, 1 stop bit. Another common one is '7N1'.
  176.   
  177.   Flow control is used to regulate the data flow between devices, if there
  178.   is some sort of limitation, such as a slow device. There is 'Software
  179.   Flow Control' using special characters, XON and XOFF, to regulate the flow.
  180.   This method is not useful for transmitting non-textual data.
  181.   'Hardware Flow Control' uses the RTS and CTS signals instead of special
  182.   characters. The receiver sets CTS to space when it is ready to receive,
  183.   and to mark when it's not. The sender uses RTS the same way. This method
  184.   is faster than Software Flow Control, since it uses a separate set of 
  185.   signals instead of extra bits.
  186.   
  187.   Since the receive or transmit signal is at mark voltage until a new character
  188.   is sent. A 'break' condition exists when the line is set to low for 1/4 
  189.   to 1/2 a second. It is used to reset a communications line, or change
  190.   the operation mode of devices like modems.
  191.  
  192.   8. Basic port programming
  193.   
  194.   Hopefully, all of the above is reasonably clear to you, so you may proceed
  195.   to program with confidence!
  196.   
  197.   In UNIX all system devices are treated as (special) files. All serial ports
  198.   are opened, read from, written to, and closed, just like a binary file.
  199.   In Linux, the PC serial ports are
  200.   
  201.      COM1 - /dev/ttyS0
  202.      COM2 - /dev/ttyS1
  203.      COM3 - /dev/ttyS2
  204.      COM4 - /dev/ttyS3
  205.   
  206.   Firstly, open the serial port as a file. However, UNIX does not allow
  207.   devices to be accessed by normal users. To solve this, either run the
  208.   program as the superuser, or change the permission on the device as root,
  209.   eg
  210.   
  211.      chmod a+rw /dev/ttyS1          (lets everyone access COM2)
  212.  
  213.   To open the file do the following. Notice the three flags used in the
  214.   open() function. O_RDWR means that we open the port for reading and
  215.   writing. O_NOCTTY specifies that the program won't be the controlling
  216.   entity for the port. Most user programs don't want this feature.
  217.   O_NDELAY means that your program ignores the DCD line. If it didn't,
  218.   the program will be put to sleep until DCD is set to 'space' voltage.
  219.   
  220.   /*
  221.   * 'open_port()' - Open serial port 1 - COM2.
  222.   *
  223.   * Returns the file descriptor on success or -1 on error.
  224.   */
  225.  
  226.  int open_port(void)
  227.  {
  228.    int fd;                                   /* File descriptor for the port */
  229.  
  230.    fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
  231.    if (fd == -1)
  232.    {                                              /* Could not open the port */
  233.      fprintf(stderr, "open_port: Unable to open /dev/ttyS1 - %s\n",
  234.              strerror(errno));
  235.    }
  236.  
  237.    return (fd);
  238.  }
  239.  
  240.  If you need to write data to the port, do something like
  241.  
  242.    n = write(fd, "ATZ\r", 4);
  243.  
  244.    if (n < 0)
  245.       puts("write() of 4 bytes failed!\n");
  246.  
  247.  Reading from the port is more complicated. If you open the port in 'raw
  248.  data' mode (the norm), each read() returns the number of characters actually
  249.  available in the serial buffers. However, if no characters are available,
  250.  read() will block until it receives characters, an interval timer expires,
  251.  or an error occurs. Use the following to make read return immediately.
  252.  FNDELAY makes read() return 0 if no characters were read.
  253.  
  254.    fcntl(mainfd, F_SETFL, FNDELAY);             /* Configure port reading */
  255.  
  256.  To close the serial port, simply use
  257.  
  258.    close(fd); 
  259.   
  260.  9. Port configuration
  261.  
  262.  This section discusses how to configure the serial port for your device.
  263.  You will need to set the terminal attributes related to the port.
  264.  To do this, include <termios.h> and access the termios structure using the
  265.  POSIX tcgetattr() and tcsetattr() functions.
  266.  
  267.  The termios structure contains
  268.  
  269.    c_cflag - Control options
  270.    c_lflag - Line options
  271.    c_iflag - Input options
  272.    c_oflag - Output options
  273.    c_cc    - Control characters
  274.    
  275.  See section 12 for a list of c_cflag control modes.
  276.  They are used to set the baud rate, parity and stop bits, and flow control.
  277.  Always enable CLOCAL and CREAD, so the program does not own the port, and so
  278.  the serial interface driver will read incoming bytes.
  279.  
  280.  9.1. Accessing the termios structure and the baud rate
  281.  
  282.  Use cfsetospeed() and cfsetispeed() to set the baud rate.
  283.  CRTSCTS might be called CNEW_RTSCTS on other systems.
  284.  The following uses a termios structure called 'options'.
  285.  For our project, the device transmitted at 9600 baud and transmitted nothing
  286.  special.
  287.  
  288.  tcgetattr(mainfd, &options);        /* Get the current options for the port */
  289.  cfsetispeed(&options, B9600);                 /* Set the baud rates to 9600 */
  290.  cfsetospeed(&options, B9600);    
  291.                                    /* Enable the receiver and set local mode */
  292.  options.c_cflag |= (CLOCAL | CREAD);
  293.        
  294.                                         /* Set the new options for the port */
  295.  tcsetattr(mainfd, TCSANOW, &options);
  296.  
  297.  The tcsetattr() function replaces the port's termios structure with the
  298.  settings you provided. The TCSANOW constant means that the changes should
  299.  occur immediately, without waiting for data transmission to complete.
  300.  Alternative choices are TCSADRAIN and TCSAFLUSH, which wait until buffers
  301.  are cleared. Refer to section 13.
  302.  
  303.  9.2. Character size and parity
  304.  
  305.  To set the character size, you must use bitwise logic.
  306.  The following code sets the character size to 8 data bits, and no parity.
  307.                          
  308.     options.c_cflag &= ~PARENB;  /* Mask character size to 8 bits, no parity */
  309.     options.c_cflag &= ~CSTOPB;
  310.     options.c_cflag &= ~CSIZE;
  311.     options.c_cflag |=  CS8;                           /* Select 8 data bits */
  312.  
  313.  For other methods, refer to section 11.
  314.  
  315.  9.3. Hardware flow control
  316.  
  317.  To enable hardware flow control, use
  318.  
  319.      options.c_cflag |= CRTSCTS;            /* Enable hardware flow control */  
  320.   
  321.  To disable it,
  322.  
  323.      options.c_cflag &= ~CRTSCTS;          /* Disable hardware flow control */  
  324.  
  325.  9.4. Canonical and raw input
  326.  
  327.  Canonical input means that all incoming characters are placed in a buffer
  328.  which may be edited by the user, until a carriage return or line feed (CR or
  329.  LF) are received. Typically, you would use
  330.  
  331.   options.c_lflag |= ~(ICANON | ECHO | ECHOE);
  332.  
  333.  Raw input is unprocessed, so they may be used as they are read.
  334.  Our device sent raw data.
  335.  
  336.   options.c_lflag &= ~(ICANON | ECHO | ISIG);
  337.  
  338.  Whether you use canonical or raw input, make sure you never enable input
  339.  echo when connected to a computer/device which is echoing characters to you.
  340.  Refer to section 14 for local mode constants.
  341.  
  342.  9.5. POSIX input modes
  343.  
  344.  Set the port's input modes for any input processing. 
  345.  Set input parity when you have enabled parity in the c_cflag part.
  346.  Usually you'd use the following to enable parity checking, and strip the
  347.  parity bit off the data, before your program reads it.
  348.   
  349.   options.c_iflag |= (INPCK | ISTRIP);
  350.   
  351.  You might use IGNPAR, which ignores all parity errors. PARMRK marks parity
  352.  errors by inserting a DEL(255) and NUL character before the bad character.
  353.  If IGNPAR is enabled, only a NUL is inserted.
  354.  
  355.  You may set software flow control using
  356.  
  357.   options.c_iflag |= (IXON | IXOFF | IXANY);
  358.  
  359.  Refer to section 15 for input mode constants.
  360.  
  361.  9.6. POSIX output modes
  362.  
  363.  To set port output modes, use the c_oflag member.
  364.  To select processed output, use the following. Of all the output modes, you
  365.  will probably only use ONCLR to convert newlines into CR and LFs.
  366.   
  367.   options.c_oflag |= OPOST;
  368.  
  369.  For raw output, use
  370.  
  371.   options.c_oflag &= ~OPOST;
  372.  
  373.  Refer to section 16 for output mode constants.
  374.  
  375.  9.7. POSIX control modes
  376.  
  377.  You may set the control characters using the c_cc part.
  378.  Set the software flow control characters in the VSTART and VSTOP
  379.  elements. The standard is DC1(17) and DC3(19) for XON and XOFF.
  380.  VMIN specifies the minimum number of 0 to read. If it is 0, then
  381.  VTIME specifies the time to wait for each character.
  382.  If VMIN is not 0, VTIME is the time to wait to read the first character.
  383.  If the first character is read, then any read() will be blocked until all
  384.  VMIN characters are read.
  385.  VTIME is specified in tenths of seconds. If it is 0, then read()s will
  386.  be permanently blocked unless NDELAY was previously specified with fcntl().
  387.  
  388.  Refer to section 17 for control mode constants.
  389.  
  390.  10. Sample program
  391.  
  392.  This program is a skeleton COM2 reader, which was used for our project.
  393.  It did not need all of the information specified above for
  394.  configuring ports. The 20ms delay is used to indicate that data coming into
  395.  the port is buffered, and is available for the next read().
  396.  
  397.  /* Better port reading program
  398.    v1.0
  399.    23-10-96
  400.    
  401.    This test program uses quasi-POSIX compliant UNIX functions to
  402.    open the ABU port and read.
  403.    
  404.    Uses termio functions to initialise the port to 9600 baud, at
  405.    8 data bits, no parity, no hardware flow control,
  406.    and features character buffering.
  407.    The 20ms delay after the port read indicates that characters are
  408.    buffered if a button is pressed many times.
  409.    
  410.    This program was derived from instructions at
  411.     http://www.easysw.com/~mike/serial/
  412.  */
  413.  
  414.  #include <stdio.h>   /* Standard input/output definitions */
  415.  #include <string.h>  /* String function definitions */
  416.  #include <unistd.h>  /* UNIX standard function definitions */
  417.  #include <fcntl.h>   /* File control definitions */
  418.  #include <errno.h>   /* Error number definitions */
  419.  #include <termios.h> /* POSIX terminal control definitions */
  420.  
  421.  /*
  422.   * 'open_port()' - Open serial port 1.
  423.   *
  424.   * Returns the file descriptor on success or -1 on error.
  425.   */
  426.  
  427.  int open_port(void)
  428.  {
  429.    int fd;                                   /* File descriptor for the port */
  430.  
  431.    fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
  432.  
  433.    if (fd == -1)
  434.    {                                              /* Could not open the port */
  435.      fprintf(stderr, "open_port: Unable to open /dev/ttyS1 - %s\n",
  436.              strerror(errno));
  437.    }
  438.  
  439.    return (fd);
  440.  }
  441.  
  442. void main()
  443. {
  444.  int mainfd=0;                                            /* File descriptor */
  445.  char chout;
  446.  struct termios options;
  447.    
  448.  mainfd = open_port();
  449.  
  450.  fcntl(mainfd, F_SETFL, FNDELAY);                  /* Configure port reading */
  451.                                      /* Get the current options for the port */
  452.  tcgetattr(mainfd, &options);
  453.  cfsetispeed(&options, B9600);                 /* Set the baud rates to 9600 */
  454.  cfsetospeed(&options, B9600);
  455.     
  456.                                    /* Enable the receiver and set local mode */
  457.  options.c_cflag |= (CLOCAL | CREAD);
  458.  options.c_cflag &= ~PARENB; /* Mask the character size to 8 bits, no parity */
  459.  options.c_cflag &= ~CSTOPB;
  460.  options.c_cflag &= ~CSIZE;
  461.  options.c_cflag |=  CS8;                              /* Select 8 data bits */
  462.  options.c_cflag &= ~CRTSCTS;               /* Disable hardware flow control */  
  463.  
  464.                                  /* Enable data to be processed as raw input */
  465.  options.c_lflag &= ~(ICANON | ECHO | ISIG);
  466.        
  467.                                         /* Set the new options for the port */
  468.  tcsetattr(mainfd, TCSANOW, &options);
  469.                          
  470.  while (1)
  471.  {
  472.    read(mainfd, &chout, sizeof(chout));          /* Read character from ABU */
  473.    
  474.    if (chout != 0)
  475.       printf("Got %c.\n", chout);
  476.  
  477.    chout=0;
  478.    usleep(20000);
  479.  }
  480.                                                     /* Close the serial port */
  481.   close(mainfd);
  482.  }
  483.  
  484.  11. Character and parity settings
  485.  
  486.     No parity (8N1): 
  487.  
  488.      options.c_cflag &= ~PARENB;
  489.      options.c_cflag &= ~CSTOPB;
  490.      options.c_cflag &= ~CSIZE;
  491.      options.c_cflag |= CS8;
  492.  
  493.     Even parity (7E1): 
  494.  
  495.      options.c_cflag |= PARENB;
  496.      options.c_cflag &= ~PARODD;
  497.      options.c_cflag &= ~CSTOPB;
  498.      options.c_cflag &= ~CSIZE;
  499.      options.c_cflag |= CS7;
  500.  
  501.     Odd parity (7O1): 
  502.  
  503.      options.c_cflag |= PARENB;
  504.      options.c_cflag |= PARODD;
  505.      options.c_cflag &= ~CSTOPB;
  506.      options.c_cflag &= ~CSIZE;
  507.      options.c_cflag |= CS7;
  508.  
  509.     Mark parity is simulated by using 2 stop bits (7M1): 
  510.  
  511.      options.c_cflag &= ~PARENB;
  512.      options.c_cflag |= CSTOPB;
  513.      options.c_cflag &= ~CSIZE;
  514.      options.c_cflag |= CS7;
  515.  
  516.     Space parity is setup the same as no parity (7S1): 
  517.  
  518.      options.c_cflag &= ~PARENB;
  519.      options.c_cflag &= ~CSTOPB;
  520.      options.c_cflag &= ~CSIZE;
  521.      options.c_cflag |= CS8;
  522.  
  523.  12. POSIX control mode flags
  524.  
  525.  The following table lists the possible control modes for c_cflag.  
  526.    
  527.    Constant     Description
  528.    ________________________
  529.    
  530.    CBAUD        Bit mask for baud rate         
  531.    B0           0 baud (drop DTR)         
  532.    B50          50 baud         
  533.    B75          75 baud         
  534.    B110         110 baud         
  535.    B134         134.5 baud         
  536.    B150         150 baud         
  537.    B200         200 baud         
  538.    B300         300 baud         
  539.    B600         600 baud         
  540.    B1200        1200 baud         
  541.    B1800        1800 baud         
  542.    B2400        2400 baud         
  543.    B4800        4800 baud         
  544.    B9600        9600 baud         
  545.    B19200       19200 baud         
  546.    B38400       38400 baud         
  547.    EXTA         External rate clock         
  548.    EXTB         External rate clock         
  549.    CSIZE        Bit mask for data bits         
  550.    CS5          5 data bits         
  551.    CS6          6 data bits         
  552.    CS7          7 data bits         
  553.    CS8          8 data bits         
  554.    CSTOPB       2 stop bits (1 otherwise)         
  555.    CREAD        Enable receiver         
  556.    PARENB       Enable parity bit         
  557.    PARODD       Use odd parity instead of even         
  558.    HUPCL        Hangup (drop DTR) on last close         
  559.    CLOCAL       Local line - do not change 'owner' of port      
  560.    LOBLK        Block job control output         
  561.    CRTSCTS      Enable hardware flow control (not supported on all platforms)         
  562.  
  563.  13. POSIX tcsetattr Constants
  564.  
  565.    Constant   Description
  566.    ______________________
  567.    
  568.    TCSANOW    Make changes now without waiting for data to complete
  569.    TCSADRAIN  Wait until everything has been transmitted
  570.    TCSAFLUSH  Flush input and output buffers and make the change
  571.  
  572.  14. POSIX Local Mode Constants
  573.  
  574.    Constant   Description
  575.    ______________________
  576.    
  577.    ISIG       Enable SIGINTR, SIGSUSP, SIGDSUSP, and SIGQUIT signals
  578.    ICANON     Enable canonical input (else raw)
  579.    XCASE      Map uppercase \lowercase (obselete)
  580.    ECHO       Enable echoing of input characters
  581.    ECHOE      Echo erase character as BS-SP-BS
  582.    ECHOK      Echo NL after kill character
  583.    ECHONL     Echo NL
  584.    NOFLSH     Disable flushing of input buffers after interrupt
  585.               or quit characters
  586.    IEXTEN     Enable extended functions
  587.    ECHOCTL    Echo control characters as ^char and delete as ~?
  588.    ECHOPRT    Echo erased character as character erased
  589.    ECHOKE     BS-SP-BS entire line on line kill
  590.    FLUSHO     Output being flushed
  591.    PENDIN     Retype pending input at next read or input char
  592.    TOSTOP     Send SIGTTOU for background output
  593.  
  594.  15. POSIX Input Mode Constants
  595.  
  596.    Constant   Description
  597.    ______________________
  598.    
  599.    INPCK      Enable parity check
  600.    IGNPAR     Ignore parity errors
  601.    PARMRK     Mark parity errors
  602.    ISTRIP     Strip parity bits
  603.    IXON       Enable software flow control (outgoing)
  604.    IXOFF      Enable software flow control (incoming)
  605.    IXANY      Allow any character to start flow again
  606.    IGNBRK     Ignore break condition
  607.    BRKINT     Send a SIGINT when a break condition is detected
  608.    INLCR      Map NL to CR
  609.    IGNCR      Ignore CR
  610.    ICRNL      Map CR to NL
  611.    IUCLC      Map uppercase to lowercase
  612.    IMAXBEL    Echo BEL on input line too long
  613.  
  614.  16. POSIX Output Mode Constants
  615.  
  616.    Constant   Description
  617.    ______________________
  618.    
  619.    OPOST      Postprocess output (not set = raw output)
  620.    OLCUC      Map lowercase to uppercase
  621.    ONLCR      Map NL to CR-NL
  622.    OCRNL      Map CR to NL
  623.    NOCR       No CR output at column 0
  624.    ONLRET     NL performs CR function
  625.    OFILL      Use fill characters for delay
  626.    OFDEL      Fill character is DEL
  627.    NLDLY      Mask for delay time needed between lines
  628.    NL0        No delay for NLs
  629.    NL1        Delay further output after newline for 100 milliseconds
  630.    CRDLY      Mask for delay time needed to return carriage to left column
  631.    CR0        No delay for CRs
  632.    CR1        Delay after CRs depending on current column position
  633.    CR2        Delay 100 milliseconds after sending CRs
  634.    CR3        Delay 150 milliseconds after sending CRs
  635.    TABDLY     Mask for delay time needed after TABs
  636.    TAB0       No delay for TABs
  637.    TAB1       Delay after TABs depending on current column position
  638.    TAB2       Delay 100 milliseconds after sending TABs
  639.    TAB3       Expand TAB characters to spaces
  640.    BSDLY      Mask for delay time needed after BSs
  641.    BS0        No delay for BSs
  642.    BS1        Delay 50 milliseconds after sending BSs
  643.    VTDLY      Mask for delay time needed after VTs
  644.    VT0        No delay for VTs
  645.    VT1        Delay 2 seconds after sending VTs
  646.    FFDLY      Mask for delay time needed after FFs
  647.    FF0        No delay for FFs
  648.    FF1        Delay 2 seconds after sending FFs
  649.  
  650.  17. POSIX Control Character Constants
  651.  
  652.    Constant   Description          Key
  653.    ______________________________________
  654.    
  655.    VINTR      Interrupt            CTRL-C
  656.    VQUIT      Quit                 CTRL-Z
  657.    VERASE     Erase                Backspace (BS)
  658.    VKILL      Kill-line            CTRL-U
  659.    VEOF       End-of-file          CTRL-D
  660.    VEOL       End-of-line          Carriage return (CR)
  661.    VEOL2      Second end-of-line   Line feed (LF)
  662.    VMIN       Minimum number of characters to read
  663.    VTIME      Time to wait for data (tenths of seconds)
  664.  
  665.  ----------------- End of Linux Serial Programming Mini-Howto -----------------
  666.  
  667.